import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/config.dart';
import 'package:finance_app/src/entities/chat_room_message_entity.dart';
import 'package:finance_app/src/widgets/chat_room/image_chat_item.dart';
import 'package:finance_app/src/widgets/chat_room/text_chat_item.dart';
import 'package:finance_app/src/widgets/chat_room/video_chat_item.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:finance_app/generated/a.dart';

class TutorialLeftChatItem extends StatelessWidget {
  final String avatar;
  final List<ChatRoomMessageEntity> contents;
  final String time;
  final ValueChanged<dynamic> onAction;

  const TutorialLeftChatItem(
      {Key key, this.avatar, this.contents, this.time, this.onAction})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return TextChatItemStyle.left(
      child: Padding(
        padding: EdgeInsets.only(left: getDp(25), top: getDp(7)),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            CircleAvatar(
              radius: getDp(16.5),
              child: Padding(
                padding: const EdgeInsets.all(6.0),
                child: SvgPicture.asset(
                  A.assetsImagesStyleAce_Assistant_Icon,
                ),
              ),
            ),
            Expanded(
                child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisSize: MainAxisSize.min,
              children: List.generate(contents.length, (index) {
                return TextChatItem(
                  isTop: index == 0,
                  content: contents[index].content,
                  actions: contents[index].actions,
                  onAction: onAction,
                );
              })
                ..add(Padding(
                  padding: EdgeInsets.only(left: getDp(13), top: getDp(10)),
                  child: Text(
                    time,
                    style: TextStyle(
                      color: aceDarkGrayColor70,
                      fontSize: getSp(12),
                      fontWeight: FontWeight.w400,
                      height: 22 / 12,
                    ),
                  ),
                )),
            )),
          ],
        ),
      ),
    );
  }
}
